package sust.cse.ruhul.jobs1;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;

import sust.cse.ruhul.service.DoNoList;
import sust.cse.ruhul.service.LocationList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ListView;
import android.widget.TextView;

public class Page_Do extends Activity
{
	/*String[]						values	= new String[] {
			"DO Number 01 - 523234234", "DO Number 02 - 523225467",
			"DO Number 03 - 454555357", "DO Number 04 - 523456734" };*/
	private ArrayAdapter<String>	listAdapter;
	private ListView				list	= null;
	
	private CheckBox	jobCompletedCheck;
	private TextView	whenKey, whenValue;
	
	private CheckBox	leavingCheck;
	private TextView	leavingKey, leavingValue;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.page_do);
		
		Bundle extras = getIntent().getExtras();
		if (extras != null) {
		    int jobid = extras.getInt("JobId");
		    int AddrSeq = extras.getInt("AddrSeq");
		    String org = extras.getString("JobNo");
		    String fulladdr = extras.getString("fulladdress");
		    String jobstrpass = extras.getString("JobStrPass");
		    String locstrpass = extras.getString("LocStrPass");
		    
		    list = (ListView) findViewById(R.id.list_do);
		    TextView address = (TextView) findViewById(R.id.address_value);
		    Button btnJob = (Button) findViewById(R.id.btn_open_job);
		    Button btnLoc = (Button) findViewById(R.id.btn_open_location);
		    
		    address.setText(fulladdr);
		    btnJob.setText(jobstrpass);
		    btnLoc.setText(locstrpass);

		    DoNoList dolist = new DoNoList(this,list,jobid,AddrSeq);
			dolist.execute(new String[]{"http://108.163.232.50:1100/LeewayWebService.asmx?op=GetAllJobs"});
		    
		}
		
		jobCompletedCheck = (CheckBox) findViewById(R.id.job_completed_check);
		whenKey = (TextView) findViewById(R.id.when_key);
		whenValue = (TextView) findViewById(R.id.when_value);
		
		leavingCheck = (CheckBox) findViewById(R.id.leaving_check);
		leavingKey = (TextView) findViewById(R.id.when_leaving_key);
		leavingValue = (TextView) findViewById(R.id.when_leaving_value);

		
		
	}
	
	public void onClick(final View v)
	{
		switch (v.getId())
		{
		case R.id.job_completed_check:
			if (jobCompletedCheck.isChecked())
			{
				whenValue.setText(new Date().toString());
				whenKey.setVisibility(View.VISIBLE);
				whenValue.setVisibility(View.VISIBLE);
			}
			else
			{
				whenKey.setVisibility(View.VISIBLE);
				whenValue.setVisibility(View.INVISIBLE);
			}
			break;
		
	case R.id.leaving_check:
		if (leavingCheck.isChecked())
		{
			leavingValue.setText(new Date().toString());
			leavingKey.setVisibility(View.VISIBLE);
			leavingValue.setVisibility(View.VISIBLE);
		}
		else
		{
			leavingKey.setVisibility(View.VISIBLE);
			leavingValue.setVisibility(View.INVISIBLE);
		}
		break;
	}
	

	}
}
